


$.widget( "custom.catcomplete", $.ui.autocomplete, {
		_renderMenu: function( ul, items ) {
			var self = this,
				currentCategory = "";
			$.each( items, function( index, item ) {
				if ( item.category != currentCategory ) {
					ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
					currentCategory = item.category;
				}
				self._renderItem( ul, item );
			});
		}
	});

        $( "#openSearchedEventByType" ).button({
            icons: {
                primary: "ui-icon-search",
                secondary :"ui-icon-search"
            },
            text: true
        });

	$(function() {


		$( "#search" ).catcomplete({
			delay: 0,
			source: arrayOfSearchParameters,
                         select: function(event, ui) {
$("input:hidden[name=hiddenSearchEventID]").val(ui.item.id);
//$( "#searchEventID" ).html( ui.item.id );
$( "#openSearchedEventByType" ).unbind();
$( "#openSearchedEventByType" ).click(function(){
var searchedEventID = $("input:hidden[name=hiddenSearchEventID]").val();
openSelectedEvent(searchedEventID);
});
                     }


            });
	});